<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #result{
            width: 600px;
        }
    </style>
</head>
<body>
    年: <input type="text" id="year"><br>
    月: <input type="text" id="month"><br>
    日: <input type="text" id="day"><br>
    <button id="btn">判断</button><br>
    <input type="text" id="result">
</body>
<script>
    var yearInp = document.getElementById("year");
    var monthInp = document.getElementById("month");
    var dayInp = document.getElementById("day");
    var btn = document.getElementById("btn");
    var resultInp = document.getElementById("result");
    
    btn.onclick = function () {

        var year = yearInp.value;
        var month = monthInp.value;
        var day = dayInp.value;

        if(year >=1000 && year <=9999 && year % 1 == 0){
            debugger;
            if(year % 4 == 0 && year % 100 != 0 || year % 400 ==0){
                debugger;
                if(month >= 1 && month <= 12 && month % 1 == 0){
                    var month = Number(month);//或者swith(month*1)
                    switch(month){
                        case 1:
                        case 3:
                        case 5:
                        case 7:
                        case 8:
                        case 10:
                        case 12:
                            if(day >= 1 && day <= 31 && day % 1 == 0){
                                if(month == 1){
                                    var day = Number(day);
                                    var a = day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 3){
                                    var day = Number(day);
                                    var a = (month - 2) * 31 + (month-2) * 29 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 5){
                                    var day = Number(day);
                                    var a = (month - 3) * 31 + 29 + (month - 4) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 7){
                                    var day = Number(day);
                                    var a = (month - 4) * 31 + 29 + (month - 5) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 8){
                                    var day = Number(day);
                                    var a = (month - 4) * 31 + 29 + (month - 5) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 10){
                                    var day = Number(day);
                                    var a = (month - 5) * 31 + 29 + (month - 7) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }
                                else if(month == 12){
                                    var day = Number(day);
                                    var a = (month - 6) * 31 + 29 + (month - 8) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }
                            }else{
                                debugger;
                                result.value = "日都能输错?";
                            }
                            break;
                        case 4:
                        case 6:
                        case 9:
                        case 11:
                            if(day >= 1 && day <= 30 && day % 1 == 0){
                                if(month == 4){
                                    var day = Number(day);
                                    var a = (month - 2) * 31 + 29 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 6){
                                    var day = Number(day);
                                    var a = (month - 3) * 31 + 29 + (month - 5) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 9){
                                    var day = Number(day);
                                    var a = (month - 4) * 31 + 29 + (month - 2) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 11){
                                    var day = Number(day);
                                    var a = (month - 5) * 31 + 29 + (month - 3) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }
                            }else{
                                result.value = "日都能输错?";
                            }
                        case 2:
                            if(day >= 1 && day <= 29 && day % 1 == 0){
                                var day = Number(day);
                                var a = (month - 1) * 31 + day;
                                result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                            }else{
                                result.value = "日都能输错?";
                            }
                            break;
                        default:
                            result.value = "意外";
                    }
                }else{
                    result.value = "月都能输错?";
                }
            }else{
                if(month >= 1 && month <= 12 && month % 1 == 0){
                    var month = Number(month);
                    switch(month){
                        case 1:
                        case 3:
                        case 5:
                        case 7:
                        case 8:
                        case 10:
                        case 12:
                            if(day >= 1 && day <= 31 && day % 1 == 0){
                                if(month == 1){
                                    var day = Number(day);
                                    var a = day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 3){
                                    var day = Number(day);
                                    var a = (month - 2) * 31 + 28 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 5){
                                    var day = Number(day);
                                    var a = (month - 3) * 31 + 28 + (month - 4) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 7){
                                    var day = Number(day);
                                    var a = (month - 4) * 31 + 28 + (month - 5) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 8){
                                    var day = Number(day);
                                    var a = (month - 4) * 31 + 28 + (month - 5) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 10){
                                    var day = Number(day);
                                    var a = (month - 5) * 31 + 28 + (month - 7) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }
                                else if(month == 12){
                                    var day = Number(day);
                                    var a = (month - 6) * 31 + 28 + (month - 8) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }
                            }else{
                                debugger;
                                result.value = "日都能输错?";
                            }
                            break;
                        case 4:
                        case 6:
                        case 9:
                        case 11:
                            if(day >= 1 && day <= 30 && day % 1 == 0){
                                if(month == 4){
                                    var day = Number(day);
                                    var a = (month - 2) * 31 + 28 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 6){
                                    var day = Number(day);
                                    var a = (month - 3) * 31 + 28 + (month - 5) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 9){
                                    var day = Number(day);
                                    var a = (month - 4) * 31 + 28 + (month - 2) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }else if(month == 11){
                                    var day = Number(day);
                                    var a = (month - 5) * 31 + 28 + (month - 3) * 30 + day;
                                    result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                                }
                            }else{
                                result.value = "日都能输错?";
                            }
                        case 2:
                            if(day >= 1 && day <= 28 && day % 1 == 0){
                                var day = Number(day);
                                var a = (month - 1) * 31 + day;
                                result.value = year + "年" + month + "月" + day + "日" + "是" + year + "年" + "的第" + a + "天";
                            }else{
                                result.value = "日都能输错?";
                            }
                            break;
                        default:
                            result.value = "意外";
                    }
                }else{
                    result.value = "月都能输错?";
                }
            }
                
        }else{
            result.value = "年都能输错?";
        }
    }
</script>
</html>